package codeforces;

import java.util.Scanner;

public class TaxiAndGroups {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int groupsCount = s.nextInt();
		int[] groupsSizes = new int[groupsCount];
		int i = 0;
		while (i < groupsCount) {
			groupsSizes[i] = s.nextInt();
			i++;
		}

		int total = 0;
		int count1 = 0;
		int count2 = 0;
		int count3 = 0;
		int count4 = 0;
		
		for (int j = groupsSizes.length - 1; j >= 0; j--) {
			int curr = groupsSizes[j];
			if(curr == 1) {
				count1++;
			} else if(curr == 2) {
				count2++;
			} else if(curr == 3) {
				count3++;
			} else if(curr == 4) {
				count4++;
			}
		}
		
		total += count4;
		total += count3;
		if(count1 > 0 && count3 > 0) {
			if(count1 >= count3) {
				count1 -= count3;
			} else {
				count1 = 0;
			}
		}

		if(count2 > 0) {
			if(count2 >= 2) {
				total += (count2 / 2);
				if(count2 % 2 != 0) {
					total += 1;
					count1 -= 2;
				} 
			} else {
				total++;
				count1 -= 2;
			}  
		}
		
		if(count1 > 0 && count1 > 4) {
			total += count1 / 4;
			if(count1 % 4 != 0) {
				total++;
			}
		} else if(count1 > 0) {
			total++;
		}
		
		System.out.println(total);
	}

}
